<template>
  <div class="">
    <div class="">
      <div class="common_title pad_b20">操作日志</div>
      <el-form :model="queryParams" ref="queryForm" class="margin_t20"  label-width="90px">
        <el-row class="flex flex_w">
          <FormItem label="搜索关键词" class="" type="input" :form="queryParams" @keyenter="handleQuery" prop="keywords" clearable />
          <FormItem label="端类型" class="" type="select" :form="queryParams" prop="client" :seleDatas="statusOptions" seleKey="id" seleName="title"  clearable />
          <FormItem label="用户" class="" type="select" :form="queryParams" prop="user_id" :seleDatas="memberOptions" seleKey="id" seleName="name" filterable clearable />
          <div class="search_btns pad_l20">
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
            <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
          </div>
        </el-row>
      </el-form>
      <div class="common_line"></div>
      <div class="common_button flex_ac">
        <div class="right_button margin_a flex">
          <a href="javascript:;" class="color_blue " @click="handleUpdate" v-if="have_auth('/system/set/add')"><img src="@/assets/add.png" class="btn_img">新增</a>
          <a href="javascript:;" class="color_red" @click="handleDelete('','delete','删除')" v-if="have_auth('/system/set/del')"><img src="@/assets/dele.png" class="btn_img">删除</a>
        </div>
      </div>
    </div>
    <div class="common_block_div">
      <el-table v-loading="loading" :data="list"  border >
        <el-table-column label="序号" align="left" prop="id"   />
        <el-table-column label="用户名" align="left" prop="username"   />
        <el-table-column label="用户ID" align="left" prop="admin_id"   />
        <el-table-column label="操作" align="left" prop="title" :show-overflow-tooltip="true" />
        <el-table-column label="IP" align="left" prop="ip"  />
        <el-table-column label="端类型" align="left" prop="client_name"  />
        <el-table-column label="时间" align="left" prop="create_time" width="220" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.limit"
        @pagination="getList"
      />
    </div>

  </div>
</template>

<script>
export default {
  name: 'needCache',
  data () {
    return {
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      activeName:'1',  // 1进行中 2 已结束
      loading: true,
      total: 0,
      // 定时任务表格数据
      list: [],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 16
      },
      openOptions: [],
      open:false,
      queryParams2:{},

      is_ajax:false,


      statusOptions:[{id:'1',title:'PC端'},{id:'2',title:'小程序端'}],
      memberOptions:[]
    }
  },
  activated() {
    this.get_options();
    this.getList();
  },
  methods:{
    get_options(){
      const _this=this;
      _this.axios.get("/api/User/index_bak", {params:{limit: 161000000000}}).then(function(res) {
        if(res){
          _this.memberOptions=res.data.data
        }
      }).catch(function(error) {
        console.log(error);
      })
    },

    /** 查询定时任务列表 */
    getList() {
      const _this=this;
      this.loading = true;
      _this.axios.get("/api/sys.Action/index", {params:this.queryParams}).then(function(res) {
        if(res){
          _this.list = res.data.data;
          _this.total = res.data.total;
          _this.loading = false;
          // _this.openOptions=_this.obj2arr(res.message.search.status)
        }
      }).catch(function(error) {
        console.log(error);
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams={
        page: 1,
        limit: 16
      }
      this.handleQuery();
    }

  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .title{line-height: 44px; font-size: 20px;}
</style>
